const db = wx.cloud.database()
  const app = getApp()
Page({
  /**
   * 页面的初始数据,可以为空
   */
  data: {
    indicatorDots: true,
    autoplay: true,
    interval: 4000,
    duration: 1000 ,
   movies:'',
    },
  onShow() {
    var that = this
    db.collection('movies').limit(4).get().then(res => {
      var movies = []
      
      for (let idx in res.data) {
        var movieObj = {
          id: res.data[idx]._id,
          title: res.data[idx].title,
          poster: res.data[idx].poster
        }
        movies.push(movieObj)
      }
      that.setData({movies: movies})
    })
    },
   toMore:function(){
    wx.switchTab({
      url: '/pages/buy/buy',
    })
   },
  onMovieTap: function (event) {
    const id = event.currentTarget.dataset.id;
    console.log(id)
    wx.navigateTo({
      url: `/pages/cinema/cinema?id=${id}`
    })
  },
  onXiangqing:function(event){
    const id = event.currentTarget.dataset.id;
    console.log(id)
    wx.navigateTo({
      url: `/pages/xiangqing/xiangqing?id=${id}`
    })
  },
  toSearch:function(){
    wx.navigateTo({
      url: `/pages/search/search?`
    })
  }
  
})